package com.sodaopen.study.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.sodaopen.study.entity.Step;

public interface StepMapper {

	@Select("select * from t_step where chapter_id=#{id} order by sort")
	List<Step> selectByChapterId(Integer id);

	@Insert("insert into t_step(title, content, chapter_id, sort) values"
			+ "(#{title}, #{content}, #{chapterId}, #{sort})")
	void insertStep(Step step);

	@Select("select ifnull(max(sort),0) from t_step where chapter_id=#{chapterId}")
	Integer selectMaxSort(Integer chapterId);

	@Update("update t_step set title=#{title}, content=#{content}, sort=${sort} where id=#{id}")
	void updateStep(Step step);

	
}
